package com.tanhua.server.controller;

import com.tanhua.domain.vo.AnnouncementVo;
import com.tanhua.domain.vo.MessageVo;
import com.tanhua.domain.vo.PageResult;
import com.tanhua.server.service.AnnounService;
import com.tanhua.server.service.IMService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;

/**
 * 消息列表--公告
 */
@RestController
@RequestMapping("/messages")
public class AnnounController {
    // 订阅 AnnounService
    @Autowired
    private AnnounService announService;

    @Autowired
    private IMService imService;

    /**
     * 公告
     *
     * @param page     当前页数
     * @param pagesize 每页条数
     * @return
     */
    @GetMapping("/announcements")
    public ResponseEntity announcements(@RequestParam(defaultValue = "1") Long page, @RequestParam(defaultValue = "10") Long pagesize) {

        return announService.announcements(page, pagesize);


    }

    /**
     * 谁对我点赞通知
     *
     * @param page     当前页数
     * @param pagesize 每页条数
     * @return
     */
    @GetMapping("/likes")
    public ResponseEntity likes(@RequestParam(defaultValue = "1") Long page, @RequestParam(defaultValue = "10") Long pagesize) {

        PageResult<MessageVo> vo = imService.messageCommentList(1, page, pagesize);
        return ResponseEntity.ok(vo);
    }
    /**
     * 谁对我评论通知
     *
     * @param page     当前页数
     * @param pagesize 每页条数
     * @return
     */
    @GetMapping("/comments")
    public ResponseEntity comments(@RequestParam(value = "page",defaultValue = "1") Long page, @RequestParam(value = "pagesize",defaultValue = "10") Long pagesize) {

        PageResult<MessageVo> vo = imService.messageCommentList(2, page, pagesize);
        return ResponseEntity.ok(vo);
    }
    /**
     * 谁对我喜欢通知
     *
     * @param page     当前页数
     * @param pagesize 每页条数
     * @return
     */
    @GetMapping("/loves")
    public ResponseEntity loves(@RequestParam(defaultValue = "1") Long page, @RequestParam(defaultValue = "10") Long pagesize) {

        PageResult<MessageVo> vo = imService.messageCommentList(3, page, pagesize);

        return ResponseEntity.ok(vo);
    }
}
